//
//  MapVc.m
//  WGFGlobalHouses
//
//  Created by welldone on 15/5/12.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "MapVc.h"
#import "BdTV.h"
#import "config.h"


@interface MapVc ()
@property (nonatomic,assign)HourseMapCellData *bufLoc;

@property (weak, nonatomic) IBOutlet MKMapView *mapView;


@end

@implementation MapVc
@synthesize bufLoc,title,subTitle;



-(id)initWithLoc:(HourseMapCellData*)loc{
    self = [super init];
    if (self) {
        bufLoc = loc;
    }
    return self;
}



-(void)setData:(HourseMapCellData *)data
{
    bufLoc = data;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    BdTV *titleV = [BdTV creatInstanceWithTitle:@"楼盘地图"];
    [titleV.backBtn setTag:11];
    [titleV.backBtn addTarget:self action:@selector(btnOnclick:) forControlEvents:UIControlEventTouchUpInside];
    [[titleV doneBtn] removeFromSuperview];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:titleV];
    
    
    
    self.mapView.mapType = MKMapTypeStandard;
    self.mapView.zoomEnabled=true;
    
    
    MKCoordinateRegion region;
    region.center.latitude = bufLoc.coordinate.latitude;
    region.center.longitude = bufLoc.coordinate.longitude;
    
    
   
    region.span.latitudeDelta = 0.1;
    region.span.longitudeDelta = 0.1;
    region = [self.mapView regionThatFits:region];
    [self.mapView setRegion:region animated:TRUE];
    
    
    [self.mapView addAnnotation:bufLoc];
    [self.mapView selectAnnotation:bufLoc animated:YES];
    [self.mapView setCenterCoordinate:bufLoc.coordinate animated:YES];
}


-(void)btnOnclick:(UIButton*)sender{
    [super btnOnclick:sender];
    
    if (sender.tag==11) {
        [self.navigationController popViewControllerAnimated:YES];
    }

}


@end
